package com.longrise.android.byjk.plugins.dealsituation.course.video2.education.assist;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.longrise.android.byjk.R;
import com.longrise.android.byjk.utils.DialogUtil;

/**
 * Created by godliness on 2017/10/18.
 * 辅助课程操作
 */

public final class CourseHelper {

//    /**
//     * 完善资料对话框
//     */
//    public static void generateCompleteProfileDialog(final Context cxt) {
//        View completeView = generateBBcurrencyDialogView(cxt);
//        TextView cancle = (TextView) completeView.findViewById(R.id.dialog_tiku_cancel);
//        TextView confrim = (TextView) completeView.findViewById(R.id.dialog_tiku_confirm);
//        TextView content = (TextView) completeView.findViewById(R.id.dialog_tiku_message);
//        content.setText(cxt.getString(R.string.buycourse_complete_infor));
//        content.setTextColor(cxt.getResources().getColor(R.color.yellow_btn99));
//        cancle.setText(cxt.getString(R.string.next_time_complete_person_profile));
//        confrim.setText(cxt.getString(R.string.complete_person_profile));
//        cancle.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                DialogUtil.getInstance().dismiss();
//                Tracker_Google.getInstance().addEvent("完善信息弹窗", "以后再说", "");
//            }
//        });
//        confrim.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                DialogUtil.getInstance().dismiss();
//                Intent intent = new Intent(cxt, InputPersonActivity.class);
//                cxt.startActivity(intent);
//                Tracker_Google.getInstance().addEvent("完善信息弹窗", "立即完善", "");
//            }
//        });
//        DialogUtil.getInstance().creatAlertDialog(cxt, completeView, 266, 171);
//    }

    /**
     * 网络状态 移动网络与wifi网络
     *
     * @param transferComform 调用来自哪里 目前课程详情页，或者视频播放页（视频播放页点击取消要退出播放器）
     */
    public static void showNetWorkStateDialog(final Context cxt, final int transferComform, final Flag.OnNextListener listener) {
        if (cxt == null) {
            return;
        }
        View netWorkStateChangeView = generateBBcurrencyDialogView(cxt);
        TextView cancle = (TextView) netWorkStateChangeView.findViewById(R.id.dialog_tiku_cancel);
        TextView confrim = (TextView) netWorkStateChangeView.findViewById(R.id.dialog_tiku_confirm);
        TextView content = (TextView) netWorkStateChangeView.findViewById(R.id.dialog_tiku_message);
        content.setText(cxt.getString(R.string.network_is_data));
        cancle.setText(cxt.getString(R.string.network_is_data_dialog_canclebtn));
        confrim.setText(cxt.getString(R.string.network_is_data_dialog_confrimbtn));
        cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogUtil.getInstance().dismiss();
                if (listener != null) {
                    //如果是播放页调用，点击取消要退出播放器页面
                    listener.onBack(transferComform == Flag.TRANSFER_COURSE_VIDEO ? true : false);
                }
            }
        });
        confrim.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogUtil.getInstance().dismiss();
                if (listener != null) {
                    listener.toNext();
                }
            }
        });
        DialogUtil.getInstance().creatAlertDialog(cxt, netWorkStateChangeView, 266, 171);
    }

    /**
     * 获取保宝App中通用的对话框布局文件
     */
    private static View generateBBcurrencyDialogView(Context cxt) {
        return LayoutInflater.from(cxt).inflate(R.layout.dialog_tiku_tips, null, false);
    }
}
